package jwdt.xadmin.added.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.added.bean.TOpinion;
import jwdt.xadmin.added.service.OpinionManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/added")
public class OpinionManageAction extends BaseAction {
	
	private OpinionManageService opinionManageService = (OpinionManageService)app.getBean("opinionManageService");
	
	@RequestMapping("/listOpinion")
	public Page doListOpinion(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TOpinion obj = (TOpinion)f.copy2Class(TOpinion.class);
		return m.getWritePage(f, opinionManageService.doList(pu, obj).toJson());
	}
	
	@RequestMapping("/addOpinion")
	public Page doAddact(Form f, Module m) throws Exception {
		TOpinion obj = (TOpinion)f.copy2Class(TOpinion.class);
		return m.getWritePage(f, opinionManageService.doAddact(obj));
	}
	
	@RequestMapping("/editOpinion")
	public Page doEditact(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		TOpinion obj = (TOpinion)f.copy2Class(TOpinion.class);
		return m.getWritePage(f, opinionManageService.doEditact(obj, id));
	}
	
	@RequestMapping("/delOpinion")
	public Page doDel(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		return m.getWritePage(f, opinionManageService.doDelact(id));
	}
	
	@RequestMapping("/shenheOpinion")
	public Page doShenhe(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		String result = f.getString("result");
		return m.getWritePage(f, opinionManageService.doUpdateState(id, result));
	}
	
	@RequestMapping("/opinionWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		f.add("obj", opinionManageService.doLoad(id));
		return m.findPage("/xadmin/added/opinionWindow");
	}
}
